package top.xylweb.common.utils;

import com.sun.org.apache.xpath.internal.SourceTree;

import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtils {
    private static Calendar calendar =Calendar.getInstance();

    /**
     * @Author X [**.**.**]
     * @Date 2017/12/19 20:47
     * Description  获取当天是周几
     **/
    public static int getWeek(){

        calendar.setTime(new Date());
        int week = calendar.get(Calendar.DAY_OF_WEEK)-1;
        if(week<0) week=7;
        return week;
    }

    /**
     * @Author X [**.**.**]
     * @Date 2017/12/19 20:55
     * Description 获取上午打卡时间 和 下午打卡时间的 分钟间隔。
     **/
    public static int getMinute(Date startDate,Date endDate){
        Long start = startDate.getTime();
        Long end =  endDate.getTime();
        int munite = (int)(end-start)/(1000*60);
        return munite;
    }

    /**
     * @Author X [**.**.**]
     * @Date 2018/1/6 11:39
     * Description 获取当天某个  时间
     **/
    public static Date getDate(int hour,int minute){
        calendar.set(Calendar.HOUR_OF_DAY,hour);
        calendar.set(Calendar.MINUTE,minute);
        return  calendar.getTime();
    }


}
